package com.geostart.constructionland.system.controller;

import com.geostar.constructionland.common.entity.analyse.AnalyseVersion;
import com.geostar.constructionland.common.entity.response.ExtJsAjaxResponse;
import com.geostart.constructionland.system.service.AnalyseVersionFeignClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

@Api
@Controller
@RequestMapping(path = "/analyse")
public class AnalyseController {
    @Autowired
    AnalyseVersionFeignClient analyseVersionFeignClient;
    @RequestMapping(path = "/profile")
    public String initPage() {

        return "profile/analyse_profile";
    }

    @PostMapping("/getAnalyseVersions")
    @ResponseBody
    @ApiOperation(value = "获取分析版本信息")
    public ExtJsAjaxResponse getAnalyseVersions(@NotBlank(message = "页码不能为空")  @RequestParam(value = "page") int pageNo,
                                                @NotBlank(message = "每页数量不能为空") @RequestParam(value = "limit") int pageNum,
                                                String analyseType,
                                                String analyseName,
                                                String query_analyse_name){
        return analyseVersionFeignClient.getAnalyseVersions(pageNo,pageNum,analyseType,analyseName,query_analyse_name);
    }

    @PostMapping("/saveAnalyseVersion")
    @ResponseBody
    @ApiOperation("保存分析版本信息")
    public ExtJsAjaxResponse saveAnalyseVersion(@Valid AnalyseVersion analyseVersion){
        return analyseVersionFeignClient.addAnalyseVersion(analyseVersion);
    }


    @PostMapping("/deleteAnalyseVersion")
    @ResponseBody
    @ApiOperation("删除版本信息")
    public ExtJsAjaxResponse deleteAnalyseVersion(@RequestParam(value = "versionId") String versionId){
        return analyseVersionFeignClient.delAnalyseVersion(versionId);
    }


    @PostMapping("/updateAnalyseVersion")
    @ResponseBody
    @ApiOperation("更新版本信息")
    public ExtJsAjaxResponse updateAnalyseVersion(AnalyseVersion analyseVersion){
        return analyseVersionFeignClient.updateAnalyseVersion(analyseVersion);
    }
}
